#!/usr/bin/env python
#_*_ coding:utf-8 _*_

from pyscript.core import task
from task.collect import CollectTask
from model.collect.dangle import DangleList
from model.collect import Game


@task
class Dangle(CollectTask):

    def init(self):
        if self.url is None:
            return 

        gameList = DangleList(**self.config)
        gameList.fopen(self.url)
        retval = gameList.getData()

        if not isinstance(retval, dict):
            return

        next_url = retval.get('next', None)

        if next_url:
           self.url = next_url 

        games = retval.get('games', [])
        print games
        gameModel = Game()

        if len(games) > 0:
            pass


